﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EzDesk.Project.Service.Repositories.Interfaces;
using EzDesk.Project.Model;

namespace EzDesk.Project.Service.Repositories
{
    public class ProjectTypeRepository : IProjectTypeRepository
    {
        private EzDeskProjectDataContext _db;

        public ProjectTypeRepository(EzDeskProjectDataContext db)
        {
            this._db = db;
        }

        // todo: DI重构
        public ProjectTypeRepository()
            :this(new EzDeskProjectDataContext())
        {}

        public Guid Add(Model.ProjectType model, bool saveChanges)
        {
            throw new NotImplementedException();
        }

        public Model.ProjectType GetById(Guid id)
        {
            throw new NotImplementedException();
        }

        public IQueryable<Model.ProjectType> GetAll()
        {
            return _db.ez_ProjectTypes
                .Select(p => new ProjectType()
                {
                    Id = p.Id,
                    Name = p.TypeName,
                    OrderNo = p.OrderNo,
                });
        }

        public void Delete(Guid id, bool saveChanges)
        {
            throw new NotImplementedException();
        }

        public void Update(Model.ProjectType model, bool saveChanges)
        {
            throw new NotImplementedException();
        }

        public void SaveChanges()
        {
            this._db.SubmitChanges();
        }
    }
}
